<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script type="text/javascript" src="/plugins/editor/editormd.js"></script>
<link rel="stylesheet" type="text/css"
	href="/plugins/editor/css/editormd.css">
<form action="/blog/addBlog" role="form" method="post">
	<div style="height: 10px;"></div>
	<div class="container">
		<div class="panel panel-default">
			<div class="panel-heading">
				发布文章
			</div>
			<div class="panel-body">
				<div class="row">
					<div class="col-md-8">
						<c:if test="${not empty msg}">
							<div class="alert alert-warning">${msg}</div>
						</c:if>
					</div>
				</div>
				<div class="row">
					<div class="col-md-4 ">
						
						<div class="input-group">
				            <span class="input-group-addon">标题</span>
				            <input name="title" value="${blog.title}" type="text" class="form-control" placeholder="5-15个字">
				        </div>
				        <br/>
				         <div class="input-group">
				           <span class="input-group-addon">类别</span>
				         	 <select name="type.id" class="form-control" >
				         	 	<c:forEach items="${types}" var="type">
				         	 	 	<option  value="${type.id}"<c:if test="${blog.type.id==type.id}">select="selected"</c:if>>${type.name }</option>
				         	 	</c:forEach>
	                         </select>
                         </div><!--input-group  -->
					</div><!-- col-md-5 -->
				</div><!-- row -->
				<div style="height: 10px;"></div>
				<h5 class="text-muted">正文内容：</h5>
                <div class="editormd" style="z-index: 5" id="test-editormd">                
                 	<textarea  style="display:none;" name="content">${blog.content}</textarea>
           		</div>
				<div style="height: 5px;"></div>
				<button type="button" onclick="publish(this)" class="btn btn-default">发布</button>
				&nbsp;
				<button type="button" class="btn btn-default">保存草稿</button>
			</div><!-- panel-body -->
		</div><!-- panel -->
	</div>
</form>
 <script type="text/javascript">
	var testEditor;
	testEditor = editormd("test-editormd", {
		width : "100%",
		height : 640,
		syncScrolling : "single",
		path : "/plugins/editor/lib/"
	});
	
	function publish(bn){
		$("form").submit();
		$(bn).attr("disabled","disabled").html("发布中");
	}
</script>
